def cal_sum(nums):
    """
    给定 n 个整数 a1,a2,⋯ ,an 求它们两两相乘再相加的和
    利用前缀和思想
    """
    n = len(nums)
    prefix_sum = [0] * (n + 1)
    for i in range(1,n + 1):
        prefix_sum[i] = prefix_sum[i - 1] + nums[i - 1]

    result = 0
    for i in range(n):
        result += nums[i] * (prefix_sum[n] - prefix_sum[i + 1])
    return result

try:
    n = int(input())
    nums = list(map(int, input().split()))
    if len(nums) != n:
        raise ValueError("输入的整数数量与预期不符")
    print(cal_sum(nums))
except ValueError as e:
    print("输入无效:", e)